package day15;

public class Demo {
	
	public static void main(String[] args){
		int num = 5;
		int result = fun(num);
		System.out.println(result);
	}

	public static int fun(int num) {
		int result = 1;
		for (int i = num; i >= 1; i--) {
			result = result * i;
		}
		return result;
	}
}


class Demo2 {
	public static void main(String[] args) {
		int num = 5;
		int result = factorial(num);
		System.out.println(result);
	}

	public static int factorial(int n) {
		System.out.println(n);
		if (n == 1) {
			return 1;
		}
		return n * factorial(n - 1);
	}
}

class Demo3 {
	public static void main(String[] args) {
		int num = 365;
		int result = factorial(num);
		System.out.println(result);
	}
	public static int factorial(int n) {
		System.out.println(n);
		if (n == 1) {
			return 1;
		}
		return n + factorial(n - 1);
	}
}
